package logic

import (
	"context"
	"models"

	"shop_srv/internal/svc"
	"shop_srv/shop_srv"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsPushLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsPushLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsPushLogic {
	return &GoodsPushLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsPushLogic) GoodsPush(in *shop_srv.GoodsPushRequest) (*shop_srv.GoodsPushResponse, error) {
	// todo: add your logic here and delete this line
	goods := models.Goods{
		Price:  in.Price,
		Stock:  in.Stock,
		Status: in.Status,
		UserId: in.UserId,
		Image:  in.Image,
		Name:   in.Name,
	}
	if err := models.DB.Create(&goods).Error; err != nil {
		return nil, err
	}
	return &shop_srv.GoodsPushResponse{}, nil
}
